home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload Trio 2
/
Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO
/
dir42
/
dg0294.zip
/
GENERIC.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-11-02
|
3KB
|
88 lines
//***************************************************************************
// GENERIC.CPP Sample DLL - called from OPAL *
//***************************************************************************
#include <stdio.h> // for our sprintf() function
#include <windows.h> // since this is a Windows DLL
#include "dll_samp.hpp" // the header file for this DLL
// DLL initialization function...
// The following #pragma is necessary with the Borland compiler ONLY...
//#pragma argsused
int FAR PASCAL LibMain (HANDLE hInstance, WORD wDataSeg, WORD wHeapSize,
LPSTR LpszCmdLine)
{
// Unlock the Local data segment if there is one...
if (wHeapSize > 0)
UnlockData (0) ;
// Any DLL-specific initialization goes here...
// If everything is okay at this point, return True...
return (1) ;
}
// The following #pragma is necessary with the Borland compiler ONLY...
//#pragma argsused
// DLL termination function (Windows Exit Procedure)...
int FAR PASCAL WEP (int nParameter)
{
// All DLL-specific cleanup code goes here...
// Exit the DLL with a return code of 1...
return 1 ;
}
//=======================================================================
// The code for each of your DLL functions goes below...
//=======================================================================
// **********************************************************************
// * Exported Function: HelloFromDLL() *
// * *
// * This function builds and displays 2 "information" Windows. *
// **********************************************************************
extern "C" // This is necessary since we are using a C++ compiler.
{
int FAR PASCAL __export HelloFromDLL ( int iIntegerIn, LPSTR lpszString,
double dDoubleIn, HWND hOpalWnd )
{
char msgString[256]; // (256 bytes for our messages below)
double dNewDouble; // (for our calculation below)
// Build a Windows message box to display the String, Integer and
// Window Handle variables passed to the DLL...
sprintf( msgString, " String: %s\n Integer: %d\n WindowHandle: %d\n",
lpszString, iIntegerIn, hOpalWnd );
MessageBox( hOpalWnd, msgString, "Message 1:",
MB_OK | MB_ICONINFORMATION );
// Multiply the double value passed to the DLL by 2...
dNewDouble = dDoubleIn * 2;
// Build a Windows message box to display the Double variable passed
// to the DLL along with the result of our multiplication...
sprintf( msgString, " Double: %f\n Double * 2 = %f\n",
dDoubleIn, dNewDouble );
MessageBox( hOpalWnd, msgString, "Message 2:",
MB_OK | MB_ICONINFORMATION );
// Exit the HelloFromDLL function returning the iIntegerIn variable
// passed to the DLL...
return (iIntegerIn);
} // (end of HelloFromDLL)
} // (end of extern "C")